home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Misc / c / Validation < prev   
Text File  |  1995-07-09  |  2KB  |  56 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Misc.Validation.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.01 (12 Dec 1992)
  14.     Purpose: Scanning of validation strings for various fields
  15. */
  16.  
  17. #include "DeskLib:Core.h"
  18. #include "DeskLib:Validation.h"
  19.  
  20.  
  21. extern int Validation_ScanString(char *string, char tag)
  22. {
  23.   register int  index;
  24.   register char trytag;
  25.  
  26.   if ((int) string <= 0 || string[0] < 32)  /* Invalid pointer/NULL string   */
  27.     return(0);
  28.  
  29.   if (tag >= 'a' && tag <= 'z')
  30.     tag &= 0xdf;                            /* Force to uppercase to compare */
  31.  
  32.   index = -1;
  33.   while (TRUE)
  34.   {
  35.     if (string[++index] < 32)               /* End of string-still not found */
  36.       return(0);
  37.  
  38.     if (string[index] >= 'a' && string[index] <= 'z')
  39.       trytag = string[index] & 0xdf;
  40.     else
  41.       trytag = string[index];               /* Force to uppercase to compare */
  42.  
  43.     if (trytag == tag)
  44.     {
  45.       if (string[index + 1] < 32)
  46.         return(0);                         /* No chars following tag!        */
  47.       else
  48.         return(index + 1);                 /* Found, so return index         */
  49.     }
  50.  
  51.     while (string[index] != ';')            /* Scan for ';' - item seperator */
  52.       if (string[++index] < 32)                                 /* not found */
  53.         return(0);
  54.   }
  55. }
  56.